<extend name="Public:base" />
<block name="title"><title>心e购-确认订单</title></block>
<block name="resources">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Wap/lib/mui/css/mui.picker.min.css"/>
	<style>
		.mui-pciker-list li {
			font-size: 0.1rem;
		}
	</style>
</block>
<block name="body">
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">确认订单</h1>
	</header>
	<div class="mui-content">
		<div class="ddxx_box">
			<div class="ddxx_title dis_flex">
				<a href="javascript:;" class="flex1 mui-text-left">收货信息</a>
				<a href="javascript:changeAddress();" class="flex1 mui-text-right">更换</a>
			</div>
			<div class="dd_mzl">
				<p>收货人：<span id="realname">{$address.realname}</span></p>
				<p>联系电话：<span id="mob_phone">{$address.mob_phone}</span></p>
				<!-- <p>邮编号码：<span>520000</span></p> -->
				<p>收货地址：<span id="address">{$address.province}{$address.city}{$address.area}{$address.address}</span></p>
			</div>
		</div>
		<form method="post">
			<input type="hidden" name="goods_id" value="{$product.id}">
			<input type="hidden" name="address_id" id="address_id">
			<input type="hidden" name="color_n" value="{$get.color_n}">
			<input type="hidden" name="spec_n" value="{$get.spec_n}">
			<input type="hidden" name="price" value="{$get.price}">
			<input type="hidden" name="point_num" value="{$get.point_num}">
			<ul class="gcw_list">
				<li class="list_box">
					<div class="mui-card-header">{$store.store_name}</div>
					<div class="gwc_list_content">
						<div class="img_box">
							<img src="{$product.pic}">
						</div>
						<div class="sp_xx">
							<div class=""><p class="sp_title mui-ellipsis">{$product.productname}</p></div>
							<div><p>颜色：<span>{$get.color_n}</span> 码数：<span>{$get.spec_n}</span></p></div>
							<div>
								<span class="num">数量：</span>
								<div class="mui-numbox" data-numbox-min="0" data-numbox-max="99">
									<!--  data-numbox-max  为数量最大值，如果库存量就把库存量放进去-->
									<button class="mui-btn mui-btn-numbox-minus" type="button" disabled="">-</button>
									<input class="mui-input-numbox" type="number" name="goods_num" value="1">
									<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
								</div>
							</div>
							<div><p class="sp_jg"><span id="showPrice">
									<if condition="$get.price gt 0">￥{$get.price}</if>
									<if condition="$get.point_num gt 0">
										<if condition="$get.price gt 0">+</if>
										积分：{$get.point_num}
									</if>
									<if condition="$product.coin_num gt 0">增值币：{$product.coin_num}</if>
								</span></p>
							</div>
						</div>
					</div>
				</li>
			</ul>
			<input class="mui-btn mui-btn-danger mui-btn-block" style="margin-top: 20px;" type="submit" value="确认提交订单" />
		</form>
	</div>
</block>
<block name="script">
	<script type="text/javascript" src="__PUBLIC__/Wap/lib/mui/libs/mui.picker.min.js" ></script>
	<script type="text/javascript" src="__PUBLIC__/Wap/lib/mui/libs/mui.poppicker.js" ></script>
	<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
	<script>
		function changeAddress() {
			mui.post('/Wap/Member/address',{},function(data) {
				var picker = new mui.PopPicker();
				picker.setData(data);
				picker.show(function (selectItems) {
					$('#address_id').prop('value', selectItems[0]['value']);
					$info = selectItems[0]['text'].split(',');
					$('#realname').text($info[0]);
					$('#mob_phone').text($info[1]);
					$('#address').text($info[2] + $info[3] + $info[4] + $info[5]);
				});
			}, 'json');
		}
		$(".mui-btn-numbox-minus").click(function() {
			TotalPrice();
		});
		$(".mui-btn-numbox-plus").click(function() {
			TotalPrice();
		});
		function TotalPrice() {
			<if condition="$get.point_num gt 0">
				var num = parseInt($('.mui-input-numbox').prop("value"));
				var goods_price = 0;
				<if condition="$get.price gt 0">
					goods_price = '￥' + ({$get.price} * num).toFixed(2) + ' + ';
				</if>
				var point_num = '积分：' + ({$get.point_num} * num);
				if(goods_price) {
					$("#showPrice").text(goods_price + point_num);
				} else {
					$("#showPrice").text(point_num);
				}
			<elseif condition="$get.price gt 0" />
				var goods_price = {$get.price};
				var num = parseInt($('.mui-input-numbox').prop("value"));
				$("#showPrice").text('￥' + (goods_price * num).toFixed(2));
			<elseif condition="$product.coin_num gt 0" />
				var coin_num = {$product.coin_num};
				var num = parseInt($('.mui-input-numbox').prop("value")) + 1;
				$("#showPrice").text('积分：' + (coin_num * num).toFixed(2));
			</if>
		}
	</script>
</block>